import { createRouter, createWebHistory } from "vue-router";

import { defineAsyncComponent } from "vue";

const layout = () => import("@/layout/commonIndex.tsx");//公共路由

export const constantRoutes = [
  {
    path: "/",
    redirect: "/index",
    component: layout,
    children: [
      {
        path: '/index',
        name: 'index',
        component: () => import("@/views/index/index.tsx")
      }
    ]
  },
];

const router = createRouter({
  routes: constantRoutes,
  history: createWebHistory("/"), //history模式使用HTML5模式
});

// router.beforeResolve((to, from, next) => {
//   window.document.title = to.meta.title
//   next()
// })



// export const routerPath = (name,isParams = false) => {
//   if(!isParams){
//     router.push(name)
//   }else{
//     router.push({
//       name,
//       params: isParams
//     })
//   }

// }

export default router;
